import numpy as np

target_vector = np.array([1,2])
names= ['sy','qq','tt','pp']
vector_sy = np.array([4,6])
vector_qq = np.array([1,2])
vector_tt = np.array([10,11])
vector_pp= np.array([1,3])
# 广播
# a = np.zeros([1,2])
vector = np.array([vector_sy,vector_qq,vector_tt,vector_pp])
# dis = np.sum(np.power(vector-target_vector,2),axis=1)
# print(dis)
# index = np.argmin(dis)
# print(names[index])

# 范数
dis_list = np.linalg.norm(vector-target_vector,axis=1)
print(dis_list)
# [('sy', 5.0), ('qq', 0.0), ('tt', 12.727922061357855), ('pp', 1.0)]
name_zip = zip(names,dis_list)
name_zip_list = list(name_zip)
print(name_zip_list)
name_zip_list = np.array(name_zip_list,dtype=object)

name_sort = np.argsort(name_zip_list[:,1])
print(name_sort)
print(name_sort[0])